package com.bdqn.t296.noso.controller;


import com.bdqn.t296.noso.entity.User;
import com.bdqn.t296.noso.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping("/userListPage")
    public String toList(Model model) { //当前显示的页码
        List<User> list=userService.likeSel("");
        model.addAttribute("usr",list);
        return "user/list";
    }
    @RequestMapping("/byIdSel")
    @ResponseBody
    public List<User> toList(@RequestParam("loginName") String loginName){
        System.out.println("loginName:"+loginName);
        List<User> list=userService.likeSel(loginName);
        return list;
    }
    @RequestMapping("/del")
    @ResponseBody
    public int byIdDle(String usrId){
        System.out.println("usrId:"+usrId);
        return userService.del(usrId);
    }


}